<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
  xmlns:s="http://jboss.org/schema/seam/taglib"
  xmlns:ui="http://java.sun.com/jsf/facelets"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:a4j="http://richfaces.org/a4j"
  xmlns:rich="http://richfaces.org/rich"
  xmlns:zanata="http://java.sun.com/jsf/composite/zanata"
  template="../WEB-INF/template/template.xhtml">

<ui:define name="page_title">
  #{msgs['jsf.Projects']} - #{projectHome.instance.name}
</ui:define>

<ui:define name="center_content">
<script type="text/javascript">
  //<![CDATA[
  jQuery(function () {
    crossroads.addRoute(':pre*:/project/view/{slug}/settings/{subSection}',
      function (pre, slug, subSection) {
        zanata.tabs.activate(jQuery('#settings_tab'));
        subSection = subSection || 'general';
        subSection = validateTab("#settings-" + subSection + '_tab', subSection, 'general');
        zanata.tabs.activate(jQuery('#settings-' + subSection + "_tab"));
      });

    crossroads.addRoute(':pre*:/project/view/{slug}/:section:',
      function (pre, slug, section) {
        section = section || 'versions';
        section = validateTab('#' + section + "_tab", section, "versions");
        zanata.tabs.activate(jQuery('#' + section + "_tab"))
      });

    updateStateFromUrl();
    renderStatistics();
  })
  //]]>

</script>

<a4j:jsFunction name="refreshStatistics" status="statistic-loader"
  render="versions_form"
  oncomplete="refreshTooltip('#{rich:clientId('versions_form')}')"
  action="#{projectHomeAction.resetPageData}"/>

<a4j:jsFunction name="renderStatistics" status="statistic-loader"
  oncomplete="refreshTooltip('#{rich:clientId('versions_form')}')"
  render="versions_form"
  action="#{projectHomeAction.setPageRendered(true)}"/>

<div class="g">
  <div class="g__item w--1-m w--3-8-l w--1-3 l--push-bottom-half">
    <p class="txt--meta l--push-all-0">
      <s:link view="/project/home.xhtml" propagation="none"
        value="#{msgs['jsf.Projects']}"/>
    </p>

    <s:div styleClass="media l--push-bottom-half" id="project-info">
      <div class="media__body">
        <h1 class="l--push-all-0">#{projectHome.instance.name}</h1>

        <p class="txt--understated">
          <s:fragment
            rendered="#{not empty projectHome.instance.description}">
            #{projectHome.instance.description}
          </s:fragment>
        </p>
      </div>

      <s:fragment
        rendered="#{not empty projectHome.instance.sourceCheckoutURL or not empty projectHome.instance.sourceViewURL}">
        <div class="d--top l--push-top-half l--pad-top-half">
          <h2 class="delta headding--secondary l--push-top-0">
            <i
              class="i--left i--source"></i> #{msgs['jsf.project.SourceCode']}
          </h2>

          <ul class="list--no-bullets txt--meta l--push-top-quarter">
            <s:fragment
              rendered="#{not empty projectHome.instance.sourceViewURL}">
              <li>
                <span class="list__title">
                  #{msgs['jsf.project.HomePage']}:
                </span>
                <a href="#{projectHome.instance.sourceViewURL}" target="_blank">
                  #{projectHome.instance.sourceViewURL}<i
                  class="i--small i--right i--external-link txt--neutral"></i>
                </a>
              </li>
            </s:fragment>
            <s:fragment
              rendered="#{not empty projectHome.instance.sourceCheckoutURL}">
              <li>
                <div class="bx--table">
                  <div class="bx--table__cell txt--nowrap">
                        <span class="list__title">
                          #{msgs['jsf.project.Repository']}:
                        </span>
                  </div>
                  <div
                    class="bx--table__cell w--1 w--1-s l--pad-left-quarter">
                    <input type="text"
                      class="form__input--copyable js-form__input--copyable"
                      readonly="readonly"
                      value="#{projectHome.instance.sourceCheckoutURL}"/>
                  </div>
                </div>
              </li>
            </s:fragment>
          </ul>
        </div>
      </s:fragment>
    </s:div>

    <s:fragment rendered="#{identity.loggedIn}">
      <ui:param name="activities"
        value="#{projectHomeAction.getProjectLastActivity()}"/>

      <s:div styleClass="panel l--push-top-half" rendered="#{not empty activities}">
        <div class="panel__header">
          <h2 class="panel__heading--small">
            #{msgs['jsf.YourLastActivity']}
          </h2>
        </div>
        <div class="l--pad-all-half">
          <ui:repeat value="#{activities}" var="activity">
            <div class="txt--meta">
              <zanata:activity-entry value="#{activity}"/>
            </div>
          </ui:repeat>
        </div>
      </s:div>
    </s:fragment>

</div>
<div class="g__item w--1-m w--5-8-l w--2-3">
  <div class="tabs--lined js-tabs">
    <ul class="tabs__nav js-tabs-nav">
      <li>
        <a id="versions_tab"
          href="#{request.contextPath}/project/view/#{projectHomeAction.slug}/versions"
          class="js-url-mod" data-content="#versions">
          <i class="i i--version"></i>
              <span class="is-hidden--s i__text--right">
                #{msgs['jsf.Versions']}
                <s:span styleClass="txt--neutral" id="versions-size">
                  #{projectHomeAction.getProjectVersions().size}
                </s:span>
              </span>
        </a>
      </li>
      <li>
        <a id="maintainers_tab"
          href="#{request.contextPath}/project/view/#{projectHomeAction.slug}/maintainers"
          class="js-url-mod" data-content="#maintainers">
          <i class="i i--users"></i>
              <span class="is-hidden--s i__text--right">
                #{msgs['jsf.Maintainers']}
                <s:span styleClass="txt--neutral" id="maintainers-size">
                  #{projectHome.instance.maintainers.size}
                </s:span>
              </span>
        </a>
      </li>
      <li>
        <a id="about_tab"
          href="#{request.contextPath}/project/view/#{projectHomeAction.slug}/about"
          class="js-url-mod" data-content="#about">
          <i class="i i--info"></i>
              <span class="is-hidden--s i__text--right">
                #{msgs['jsf.project.About']}
              </span>
        </a>
      </li>
      <s:fragment
        rendered="#{s:hasPermission(projectHome.instance, 'update')}">
        <li class="tab__end">
          <div
            class="dropdown dropdown--tab dropdown--small dropdown--right dropdown--inline js-dropdown">
            <a class="dropdown__toggle js-dropdown__toggle" href="#"
              title="#{msgs['jsf.tooltip.MoreActions']}">
              <i class="i i--ellipsis"></i>
            </a>
            <ul class="dropdown__content js-dropdown__content"
              role="content" aria-labelledby="dropdownContent">
              <li>
                <h:outputLink id="exportTMXProjectLink"
                  styleClass="i__item--right"
                  onclick="return confirm('#{msgs['jsf.ConfirmExportTMXProject']}')"
                  value="#{request.contextPath}/rest/tm/projects/#{projectHome.slug}">
                  #{msgs['jsf.ExportTMXProject']}<i
                  class="i i--export i__item__icon"></i>
                </h:outputLink>
              </li>
            </ul>
          </div>
        </li>
        <li class="tab__end">
          <a id="settings_tab"
            href="#{request.contextPath}/project/view/#{projectHomeAction.slug}/settings"
            class="js-url-mod" data-content="#settings"
            title="#{msgs['jsf.project.ProjectSettings']}">
                    <span class="is-hidden--s i__text--left">
                      #{msgs['jsf.Settings']}
                    </span>
            <i class="i i--settings"></i>
          </a>
        </li>
      </s:fragment>
    </ul>

    <ul class="tabs__content panels__container js-tabs-content l--push-top-1">
      <li id="versions">
        <ui:include
          src="../WEB-INF/layout/project/versions-tab.xhtml"/>
      </li>

      <li id="maintainers">
        <zanata:maintainers-tab
          listSize="#{projectHome.instanceMaintainers.size}"
          filterActionBean="#{projectHome.maintainerFilter}"
          settingsUrl="#settings-permissions"
          PermissionToUpdate="#{s:hasPermission(projectHome.instance, 'update')}"/>
      </li>

      <li id="about">
        <s:div id="project-about">
          <s:formattedText value="#{projectHome.instance.homeContent}"
            rendered="#{not empty projectHome.instance.homeContent}"/>
          <s:fragment rendered="#{empty projectHome.instance.homeContent}">
            #{msgs['jsf.project.NoHomeContent']}
          </s:fragment>
        </s:div>
      </li>

      <s:fragment
        rendered="#{s:hasPermission(projectHome.instance, 'update')}">
        <li id="settings">
          <ui:include
            src="../WEB-INF/layout/project/settings-tab.xhtml"/>
        </li>
      </s:fragment>
    </ul>

    </div>
  </div>
</div>
</ui:define>
</ui:composition>
